{js:artTemplate}
<script type='text/javascript' src='{theme:javascript/artTemplate/area_select.js}'></script>

<div class="headbar">
	<div class="position"><span>系统</span><span>></span><span>自提点管理</span><span>></span><span>自提点管理编辑</span></div>
</div>
<div class="content_box">
	<div class="content form_content">
		<form action='{url:/system/takeself_update}' method='post' name='takeself'>
			<input type='hidden' name='id' value=""/>
			<table class="form_table">
				<col width="150px" />
				<col />
				<tr>
					<th>名称：</th>
					<td>
						<input type='text' class='normal' name='name' value='{$this->takeselfRow['name']}' pattern='required' alt="填写名称" />
						<label>*自提点名称（必填）</label>
					</td>
				</tr>
				<tr>
					<th>地区：</th>
					<td>
						<select name="province" child="city,area" onchange="areaChangeCallback(this);" class="auto"></select>
						<select name="city" child="area" parent="province" onchange="areaChangeCallback(this);" class="auto"></select>
						<select name="area" parent="city" class="auto"></select>
					</td>
				</tr>
				<tr>
					<th>地址：</th>
					<td>
						<input type='text' class='normal' name='address' value='{$this->takeselfRow['address']}' pattern='required' alt="填写名称" />
						<label>*具体地址（必填）</label>
					</td>
				</tr>
				<tr>
					<th>固定电话：</th>
					<td>
						<input type='text' class='normal' name='phone' value='{$this->takeselfRow['phone']}' pattern='required' alt="填写名称" />
						<label>*自提点固定电话（必填）</label>
					</td>
				</tr>
				<tr>
					<th>手机：</th>
					<td>
						<input type='text' class='normal' name='mobile' value='{$this->takeselfRow['mobile']}' pattern='required' alt="填写名称" />
						<label>*自提点负责人手机（必填）</label>
					</td>
				</tr>
				<tr>
					<th>排序：</th>
					<td>
						<input type='text' class='normal' name='sort' value='{$this->takeselfRow['sort']}' pattern='' alt="填写名称" />
						<label>数据排序,数字越小越靠前</label>
					</td>
				</tr>
				<tr>
					<th></th>
					<td>
						<button class='submit' type='submit'><span>确 定</span></button>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>

<script type='text/javascript'>
	//DOM加载完毕
	$(function(){
		//初始化地域联动
		template.compile("areaTemplate",areaTemplate);

		//修改模式
		{if:isset($this->takeselfRow)}
			var formObj = new Form('takeself');
			formObj.init({echo:JSON::encode($this->takeselfRow)});

			//城市设置
			{if:isset($this->takeselfRow['area'])}
				createAreaSelect('province',0,"{$this->takeselfRow['province']}");
				createAreaSelect('city',"{$this->takeselfRow['province']}","{$this->takeselfRow['city']}");
				createAreaSelect('area',"{$this->takeselfRow['city']}","{$this->takeselfRow['area']}");
			{else:}
				createAreaSelect('province',0,"");
			{/if}
		{else:}
			createAreaSelect('province',0,'');
		{/if}
	});

	/**
	 * 生成地域js联动下拉框
	 * @param name
	 * @param parent_id
	 * @param select_id
	 */
	function createAreaSelect(name,parent_id,select_id)
	{
		//生成地区
		$.getJSON("{url:/block/area_child}",{"aid":parent_id,"random":Math.random()},function(json)
		{
			$('[name="'+name+'"]').html(template.render('areaTemplate',{"select_id":select_id,"data":json}));
		});
	}
</script>
